home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Celestin Apprentice 7
/
Apprentice-Release7.iso
/
Source Code
/
Pascal
/
Snippets
/
PNL Libraries
/
MyAssertions.p
< prev
next >
Wrap
Text File
|
1997-03-20
|
1KB
|
72 lines
unit MyAssertions;
interface
uses
Types;
{$ifc undefined do_debug}
{$setc do_debug := 1}
{$endc}
{$ifc not do_debug}
{ buggy compiler $ d efinec Assert(b)}
{$definec Assert(b) if false & (b) then begin end else begin end }
{$definec SafeDebugStr(s)}
{$elsec}
{$definec Assert(b) AssertCode(b)}
{$definec SafeDebugStr(b) DebugStr(s)}
{$endc}
{$ifc do_debug}
procedure AssertCode (b: boolean);
procedure AssertValidPtr (p: univ Ptr);
procedure AssertValidPtrNil (p: univ Ptr);
procedure AssertValidHandle (hhhh: univ Handle);
procedure AssertValidHandleNil (hhhh: univ Handle);
{$endc}
implementation
uses
Memory;
{$ifc do_debug}
procedure AssertCode (b: boolean);
begin
if not b then begin
DebugStr('Assert Failed;sc;hc');
end;
end;
procedure AssertValidPtr (p: univ Ptr);
begin
Assert((p <> nil) & (not odd(ord4(p))));
end;
procedure AssertValidPtrNil (p: univ Ptr);
begin
if p <> nil then begin
AssertValidPtr(p);
end;
end;
procedure AssertValidHandle (hhhh: univ Handle);
begin
AssertValidPtr(hhhh);
AssertValidPtr(hhhh^);
Assert(RecoverHandle(hhhh^) = hhhh);
end;
procedure AssertValidHandleNil (hhhh: univ Handle);
begin
if hhhh <> nil then begin
AssertValidHandle(hhhh);
end;
end;
{$endc}
end.